package javax.core.security.entity;

import javax.core.security.entity.credential.AuthCredential;
import java.util.Collection;

/**
 * 用户鉴权基础类, 该类对象通常用于
 * 进行登录验证后，返回的鉴权信息对象
 */
public class UserAuthentication<T> {
    private T userEntity;
    private UserPrincipal principal;
    private AuthCredential credentials;
    private Collection<String> authorities;
    private boolean isAuthenticated;
    private String authToken;
    private long timeoutMilliSec;

    public UserAuthentication(AuthCredential credentials) {
        this.credentials = credentials;
    }

    public UserAuthentication(T userEntity, UserPrincipal principal) {
        this.userEntity = userEntity;
        this.principal = principal;
    }

    public T getUserEntity() {
        return userEntity;
    }

    public void setUserEntity(T userEntity) {
        this.userEntity = userEntity;
    }

    public UserPrincipal getPrincipal() {
        return principal;
    }

    public void setPrincipal(UserPrincipal principal) {
        this.principal = principal;
    }

    public AuthCredential getCredentials() {
        return credentials;
    }

    public void setCredentials(AuthCredential credentials) {
        this.credentials = credentials;
    }

    public Collection<String> getAuthorities() {
        return authorities;
    }

    public void setAuthorities(Collection<String> authorities) {
        this.authorities = authorities;
    }

    public boolean isAuthenticated() {
        return isAuthenticated;
    }

    public void setAuthenticated(boolean authenticated) {
        isAuthenticated = authenticated;
    }

    public String getAuthToken() {
        return authToken;
    }

    public void setAuthToken(String authToken) {
        this.authToken = authToken;
    }

    public long getTimeoutMilliSec() {
        return timeoutMilliSec;
    }

    public void setTimeoutMilliSec(long timeoutMilliSec) {
        this.timeoutMilliSec = timeoutMilliSec;
    }
}
